define(['egis'],
    function (egis) {
        Window.deserializer = Window.deserializer || new egis.core.Deserializer();
        Window.container = Window.container || {};
        dsBridge.register('create_DrawTool', function (sourceId, commandId, layerId, elementId, content, activeCommandName, canContinue) {
            var layer = Window.container[layerId];
            var element = Window.container[elementId];
            var jsonObj = Window.deserializer.createJsInstance(JSON.parse(content));
            element.geometry = jsonObj.geometry;
            element.symbol = jsonObj.symbol;
            var drawTool = new egis.draw.DrawTool({
                id: commandId,
                templateElement: element,
                drawLayer: layer,
                activeCommandName: activeCommandName,
                canContinue: canContinue
            });
            drawTool.onEndDraw = function (element) {
                Window.container[element.id] = element;
                dsBridge.call("egis.DrawTool_onEndDraw", [sourceId, JSON.stringify(element)]);
            }
            Window.container[sourceId] = drawTool;
        });

        dsBridge.register('DrawTool_onClick', function (sourceId, param) {
            try {
                var drawTool = Window.container[sourceId];
                if (!!drawTool) {
                    drawTool.onClick(param);
                }
            }
            catch (e) {
                alert(e)
            }
        });
    })